package com.vogue.supplymall.entmanagement.domain.provider;

import com.vogue.ssm.database.provider.BaseSqlProvider;
import com.vogue.ssm.database.util.DealStatus;
import com.vogue.supplymall.common.domain.dto.LicenceShopSearchInfo;

/**
 * The type Licence shop warning provider.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-04-17
 */
public class LicenceShopWarningProvider extends BaseSqlProvider {

    /**
     * Find string.
     *
     * @param licenceShopSearchInfo the licence shop search info
     * @return the string
     */
    public String find(LicenceShopSearchInfo licenceShopSearchInfo) {
        StringBuilder builder = new StringBuilder();
        builder.append(" SELECT ")
                .append(" la.id + la1.id sum ")
                .append(" FROM ")
                .append(" (select COUNT(id) id from licence_apply where applytype <> 0 and applystatue <> 1 and syscodeid = #{syscodeid} and disabledflag = 0) la, ")
                .append(" (select COUNT(lad.id) id from licence_apply_detail lad,licence_apply la where la.id = lad.applyid and lad.syscodeid = #{syscodeid} ")
                .append(" and DATEDIFF(lad.enddate,NOW()) < 30 and lad.disabledflag = 0 and la.applytype <> 0 ) la1 ");
        return DealStatus.formatShadeSql(builder.toString());
    }
}
